home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Resources
/
Chat & Communication
/
Digsby build 37
/
digsby_setup.exe
/
lib
/
oscar
/
ssi
/
SSIviewer.pyo
(
.txt
)
< prev
Wrap
Python Compiled Bytecode
|
2008-10-13
|
4KB
|
160 lines
# Source Generated with Decompyle++
# File: in.pyo (Python 2.5)
import wx
import string
import time
import struct
import oscar.ssi as oscar
import gui
class SSIViewer(wx.Frame):
def __init__(self, o, parent, id = -1):
print 'new ssiViewer'
self.o = o
wx.Frame.__init__(self, parent, id, 'SSIs')
gui.toolbox.persist_window_pos(self, close_method = self.on_close)
self.content = wx.BoxSizer(wx.VERTICAL)
tree_id = wx.NewId()
self.tree = wx.TreeCtrl(self, tree_id)
self.content.Add(self.tree, 1, wx.GROW)
rootId = self.tree.AddRoot('Root')
rootgroup = self.o.ssimanager.ssis[(0, 0)]
groups = []
if rootgroup.tlvs and 200 in rootgroup.tlvs:
for group_id in rootgroup.tlvs[200]:
groups.append(self.o.ssimanager.ssis[(group_id, 0)])
rootMemberId = self.tree.AppendItem(rootId, rootgroup.name)
if rootgroup.tlvs:
for key in rootgroup.tlvs.keys():
self.tree.AppendItem(rootMemberId, printTLV(key, rootgroup.tlvs[key]))
self.addrootgroup(rootMemberId)
for group in groups:
groupitem_id = self.tree.AppendItem(rootId, 'Name: "' + group.name + '" Group: 0x%04X' % group.group_id)
self.addgroup(group, groupitem_id)
self.SetSizer(self.content)
def addgroup(self, group, treeId):
ssilist = []
if group.tlvs and 200 in group.tlvs:
for short in group.tlvs[200]:
ssilist.append(self.o.ssimanager.ssis[(group.group_id, short)])
for member in ssilist:
memberId = self.tree.AppendItem(treeId, 'Name: "' + member.name + '" ' + ' Item #: 0x%04X' % member.item_id)
if member.tlvs:
for key in member.tlvs.keys():
self.tree.AppendItem(memberId, printTLV(key, member.tlvs[key]))
def addrootgroup(self, treeId):
ssilist = self.o.ssimanager.get_ssis_in_group(0)
for member in ssilist:
member = member.clone()
if member.type in oscar.ssi.buddy_types:
type = oscar.ssi.buddy_types[member.type]
else:
type = 'Unknown flag type 0x%04X' % member.type
memberId = self.tree.AppendItem(treeId, 'Name: "' + member.name + '" ' + ' Item #: 0x%04X' % member.item_id + ' Type: ' + type)
if member.tlvs:
for key in member.tlvs.keys():
try:
self.tree.AppendItem(memberId, printTLV(key, member.tlvs[key]))
continue
except Exception:
print 'couldnt add tlv to tree: %r' % ((key, member.tlvs[key]),)
continue
None<EXCEPTION MATCH>Exception
def on_close(self, e):
self.Destroy()
def printTLV(tlvtype, tlvdata):
import util as util
tlvstring = '0x%04X' % tlvtype + ': '
if tlvtype == 109:
(dateint,) = struct.unpack('!I', tlvdata[:4])
tlvstring = tlvstring + '"' + time.asctime(time.localtime(dateint)) + '" + '
tlvdata = tlvdata[4:]
if tlvtype == 103:
(dateint,) = struct.unpack('!I', tlvdata)
tlvstring = tlvstring + '"' + time.asctime(time.localtime(dateint)) + '"'
tlvdata = None
if tlvtype == 110:
pass
if tlvtype == 200:
for short in tlvdata:
tlvstring += '%04X' % short + ' '
tlvstring = tlvstring[:-1]
tlvdata = None
if tlvtype == 305:
tlvstring += 'Alias: "' + return_printable(tlvdata)
tlvdata = None
if tlvtype == 311:
tlvstring += 'mail: "' + return_printable(tlvdata)
tlvdata = None
if tlvtype == 311:
tlvstring += 'SMS: "' + return_printable(tlvdata)
tlvdata = None
if tlvtype == 316:
tlvstring += 'Comment: "' + return_printable(tlvdata)
tlvdata = None
if tlvtype == 213:
pass
if tlvdata:
try:
tlvstring += '"' + util.to_hex(tlvdata) + '"'
except Exception:
print tlvtype, tlvdata
raise
except:
None<EXCEPTION MATCH>Exception
None<EXCEPTION MATCH>Exception
return tlvstring
def return_printable(string_):
retval = ''
if not string_:
return ''
for char in string_:
if char in string.printable:
retval += char
continue
retval += '.'
return retval + '"'